home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / lynx-2.4 / utils / lpansi / lpansi.c next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  1.2 KB  |  58 lines

  1. /* This program allows printing of files from any VT100 or ANSI by simply 
  2.    calling the program name and a filename argument.
  3.    Written by: Gary Day, 11/30/93
  4.    Hey, it doesn't have to be complicated to be useful.
  5. */
  6.  
  7. /* Ansi C function prototypes */
  8. void ansi_printer_on(void);
  9. void ansi_printer_off(void);
  10. int main(int argc, char *argv[]);
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14.  
  15. int main(int argc, char *argv[])
  16. {
  17.   int  ch;    /* Where we store our characters */
  18.   FILE *fp;   /* File pointer */
  19.   if (argc!=2)
  20.    {
  21.     printf("Usage is lpansi <filename>\n");
  22.     exit(1);
  23.    }
  24. /* If you got here, then there is only 1 filename argument - correct */
  25.   if ((fp=fopen(argv[1], "r"))==NULL)
  26.   {
  27.    printf("Can't open %s\n",argv[1]);
  28.    exit(1);
  29.   }
  30. /* Ok, the filename was there, lets do it! */
  31.  
  32.   ansi_printer_on();
  33.  
  34.   while ((ch=getc(fp))!=EOF)
  35.   {
  36.    putc(ch,stdout);
  37.   }
  38.   fclose(fp);
  39.   
  40.   printf("\n\x0C");  /* Do a form feed at the end of the document */
  41.  
  42.   ansi_printer_off();
  43.  
  44.   return 0;  /* Return a zero if everything is ok */
  45.  
  46. /* Send a printer on escape sequence */
  47. void ansi_printer_on(void)
  48. {
  49.   printf("\x1B[5i");
  50. }
  51.  
  52. /* Send a printer off escape sequence */
  53. void ansi_printer_off(void)
  54. {
  55.   printf("\x1B[4i");
  56. }
  57.